﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Cstudy.Tools
{
    public class DirectoryHelp
    {
        public static bool Create(string directory)
        {
            while (!Directory.Exists(directory))
            {
                if (!Directory.Exists(GetParentDir(directory)))
                {
                    Create(GetParentDir(directory));
                }
                Directory.CreateDirectory(directory);
            }
            return true;
        }

        public static string GetParentDir(string path)
        {
            return path.Substring(0, path.LastIndexOf('\\'));
        }
    }
}
